﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonSearchModule
{
    /// <summary>
    /// 排序依据
    /// </summary>
    public enum SortBy
    {
        /// <summary>
        /// 上架时间
        /// </summary>
        PackageTime,
        /// <summary>
        /// 价格(高到低)
        /// </summary>
        ProductPrice_Desc,
        /// <summary>
        /// 价格(高到低)
        /// </summary>
        ProductPrice_Asc,
        /// <summary>
        /// 按课程数
        /// </summary>
        Hours,
        /// <summary>
        /// 按学生人员
        /// </summary>
        Students,
    }
    public enum SearchUrlType
    {
        Res_Item = 1,
        XiaoBan = 4,
        MingShi = 3,
    }

    /// <summary>
    /// 页面查询时的查询参数
    /// </summary>
    public class QueryTerm
    {
        #region Methods

        /// <summary>
        /// 查询参数是否为空
        /// </summary>
        /// <returns></returns>
        public bool IsNullQuery()
        {
            return string.IsNullOrEmpty(KeyWord)
                   && string.IsNullOrEmpty(CategoryName)
                   && string.IsNullOrEmpty(PropertyName)
                   && string.IsNullOrEmpty(MinPrice)
                   && string.IsNullOrEmpty(MaxPrice);
        }

        #endregion Methods

        #region Fields

        private int _PageIndex = 1;
        private int _PageSize = 10;

        #endregion Fields

        #region Properties

        /// <summary>
        /// 页大小(默认为10)
        /// </summary>
        public int PageSize
        {
            get
            {
                if (_PageSize < 1) _PageSize = 10;
                return _PageSize;
            }
            set { _PageSize = value; }
        }

        /// <summary>
        /// 页码(默认为1)
        /// </summary>
        public int PageIndex
        {
            get
            {
                if (_PageIndex < 1) _PageIndex = 1;
                return _PageIndex;
            }
            set { _PageIndex = value; }
        }

        /// <summary>
        /// 关键词
        /// </summary>
        public string KeyWord { get; set; }

        /// <summary>
        /// 分类名称
        /// </summary>
        public string CategoryName { get; set; }

        /// <summary>
        /// 属性名称
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// 最低价
        /// </summary>
        public string MinPrice { get; set; }

        /// <summary>
        /// 最高价
        /// </summary>
        public string MaxPrice { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int SortBy { get; set; }

        /// <summary>
        /// 内容类型，可能一个索引文件中有多种内容组成
        /// </summary>
        public string SearchUrlType { get; set; }
        #endregion Properties
    }
}